package test0109;

import java.io.*;

public class Test04 {
    public static void main(String[] args) throws IOException {
        // (4)把d盘下的文件拷贝到e盘下
         copy("d:/a.txt","d:/b.txt");
    }

    public static void copy(String source, String target) throws IOException {
        FileReader fileReader = new FileReader(source);
        BufferedReader bufferedReader = new BufferedReader(fileReader);
        FileWriter fileWriter = new FileWriter(target,true);
        BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
        String str = "";
        while ((str = bufferedReader.readLine())!= null){
            bufferedWriter.write(str);
            bufferedWriter.newLine();
        }
        bufferedWriter.close();
        fileWriter.close();
        bufferedReader.close();
        fileReader.close();

    }
}

